#pragma once
#include <regex>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/split_member.hpp>

using namespace std;

class CSerializableRegex
{
public:
	CSerializableRegex(void);
	~CSerializableRegex(void);
	CSerializableRegex(const wregex& regex, const wstring& str)
	{
		_regex = regex;
		_str = str;
	}

	const wregex& GetRegex()
	{
		return _regex;
	}

private:
	wregex _regex;
	wstring _str;

	//for serialization
	friend class boost::serialization::access;
    template<class Archive>
    void save(Archive & ar, const unsigned int version) const
    {        
        ar & _str;
    }
    template<class Archive>
    void load(Archive & ar, const unsigned int version)
    {        
        ar & _str;
		_regex = wregex(_str);
    }
    BOOST_SERIALIZATION_SPLIT_MEMBER()

};

